package com.atguigu4.search_sort.exer1;

/**
 * ClassName: ArrayExoer01
 * Package: com.atguigu4.search_sort.exer1
 * Description:
 *案例1：数组的扩容:
 *
 * 现有数组 int[] arr = new int[]{1,2,3,4,5};
 * 现将数组长度扩容1倍，并将10,20,30三个数据添加到arr数组中，如何操作？
 * @Author xiao_qi
 * @Create 2024/3/15 13:26
 * @Version 1.0
 */
public class ArrayExoer01 {
    public  static  void main(String[] args){
        int[] arr = new int[]{1,2,3,4,5};
        int[] arr1 = new  int[arr.length << 1];

        for (int i = 0; i < arr.length; i++) {
            arr1[i] = arr[i];
        }
        arr1[arr.length] = 10;
        arr1[arr.length +1] =20;
        arr1[arr.length + 2]= 30;
        for (int i = 0; i < arr1.length ; i++) {
            System.out.print(arr1[i] + "\t");
        }
    }
}
